﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ScoreList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get the session state to display related content
        m_MainPage = (KaohePage)Page;
        //Get title from main logic
        
        //Label_Title = m_MainPage.MainLogic.GetContentTitle();

        string curUserName = (string)Session[Engine.m_Usnkey];
        //get dpt by curUserName

        StaffDB db = new StaffDB();
        StaffDetail staffInfo = db.GetStaffBySNum(int.Parse(curUserName));

        DepartmentDb dptdb = new DepartmentDb();
        Label_Title.Text = dptdb.GetDepartmentNameById(staffInfo.DepartmentNum);

        
        ObjectDataSource_Staff.SelectParameters["DepartmentNum"].DefaultValue = staffInfo.DepartmentNum.ToString();


    //    //Get dataset from main logic
    //    if(Request.QueryString["NavButton"] == ButtonCmd.SelfScore.ToString())
    //    {

    //        //Display self score
    //        string SelfName = (string)Session[Engine.m_Usnkey];
    //        ObjectDataSource_Staff.SelectParameters.Add("UserName",SelfName);
    //        ObjectDataSource_Staff.SelectMethod = "GetScoreByName";
    //        ObjectDataSource_Staff.EnablePaging = false;
            
    //    }
    //    else if (Request.QueryString["NavButton"] == ButtonCmd.MemberScores.ToString())
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetStaffScoreList";
    //    }
    //    else if (Request.QueryString["NavButton"] == ButtonCmd.DivisionList.ToString())
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetDepartmentList";
    //    }
    //    else if (Request.QueryString["NavButton"] == ButtonCmd.MemberList.ToString())
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetMemberList";
    //        ObjectDataSource_Staff.DataObjectTypeName = "StaffDetail";
    //        ObjectDataSource_Staff.InsertMethod = "InsertStaff";
    //    }
    //    else //set the default command
    //     {
    //         SetDefaultDataSource();
    //    }
    //}

    //private void SetDefaultDataSource()
    //{
    //    if (m_MainPage.MainLogic.GetFirstButtonCmd() == ButtonCmd.SelfScore)
    //    {

    //        //Display self score
    //        string SelfName = (string)Session[Engine.m_Usnkey];
    //        ObjectDataSource_Staff.SelectParameters.Add("UserName", SelfName);
    //        ObjectDataSource_Staff.SelectMethod = "GetScoreByName";
    //        ObjectDataSource_Staff.EnablePaging = false;

    //    }
    //    else if (m_MainPage.MainLogic.GetFirstButtonCmd() == ButtonCmd.MemberScores)
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetStaffScoreList";
    //    }
    //    else if (m_MainPage.MainLogic.GetFirstButtonCmd() == ButtonCmd.DivisionList)
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetDepartmentList";
    //    }
    //    else if ( m_MainPage.MainLogic.GetFirstButtonCmd() == ButtonCmd.MemberList)
    //    {
    //        ObjectDataSource_Staff.EnablePaging = true;
    //        ObjectDataSource_Staff.SelectMethod = "GetMemberList";
    //        ObjectDataSource_Staff.DataObjectTypeName = "StaffDetail";
    //        ObjectDataSource_Staff.InsertMethod = "InsertStaff";
    //    }
    }

    private KaohePage m_MainPage = null;
    private DataComponent m_dc = new DataComponent();
    protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {

    }
    protected void ObjectDataSource_Webservice_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        IDictionary paramsFromPage = e.InputParameters;

    }
    protected void ObjectDataSource_Webservice_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        IDictionary paramsFromPage = e.InputParameters;
    }
}
